define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dts.wages.merits/index' + location.search,
                    add_url: 'dts.wages.merits/add',
                    edit_url: 'dts.wages.merits/edit',
                    del_url: 'dts.wages.merits/del',
                    multi_url: 'dts.wages.merits/multi',
                    import_url: 'dts.wages.merits/import',
                    table: 'dts_wages_merits',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'payable_total', title: __('Payable_total'), operate: false},
                        {field: 'monthly_grant', title: __('Monthly_grant'), operate: false},
                        {field: 'prepaid_amount', title: __('Prepaid_amount'), operate: false},
                        {field: 'leave_deduction', title: __('Leave_deduction'), operate: false},
                        {field: 'liquidation_issued', title: __('Liquidation_issued'), operate: false},
                        {field: 'share_equally', title: __('Share_equally'), operate: false},
                        {field: 'actual_total', title: __('Actual_total'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
